{% extends "base/_base.html" %}
{% load staticfiles %}


{% block  title %}{{ view.model_meta.verbose_name }}{% endblock %}

{% block page-content %}

    {% add view.model_meta.app_label ":" view.model_meta.model_name as viewname %}
    {% add viewname "_add" as viewname_add %}
    {% add viewname "_detail" as viewname_detail %}
    {% add viewname "_update" as viewname_update %}
    {% add viewname "_delete" as viewname_delete %}
    {% url viewname_delete as objects_delete %}

    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-lg-10">
            <h2>信息管理</h2>
            <ol class="breadcrumb">
                <li>{% url 'index' as index %}
                    <a href="{% firstof index '/' %}">主页</a>
                </li>
                <li class="active">
                    <strong>{{ view.model_meta.verbose_name }}</strong>
                </li>
            </ol>
        </div>
        <div class="col-lg-2">

        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row"><div class="col-lg-12">

            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>数据列表</h5>
                </div>
                <div class="ibox-content">

                      <div class="table-responsive">{% url viewname_add as obj_add %}

                        <div class="col-md-4">
                            {% if obj_add %}<a href="{{ obj_add }}" class="btn btn-primary">添加</a>{% endif %}
                            {% if objects_delete %}<a class="btn btn-danger">批量删除</a>{% endif %}
                        </div>
                        {% if view.filter_orm %}{% block filter-orm %}
                        <!-- 自定义ORM搜索框列表 -->
                        {% endblock %}{% endif %}
                        {% if view.filter_fields %}
                        <!-- 通用字段搜索框 -->
                        <div class="col-md-8 form-inline">
                            <div class="form-group pull-right">
                                <label class="control-label" for="quantity">搜索/过滤:</label>
                                <input type="text" class="form-control"
                                 name="s" value="{{ request.GET.s }}" 
                                 placeholder="{{ view.filter_fields|join:', ' }}"
                                 title="{{ view.filter_fields|join:', ' }}"
                                 onkeydown="if((event.keyCode==13)&amp;&amp;(this.value!=''))window.location='?s='+this.value.replace(/^\s+|\s+$/g,'');"
                                />
                                <!-- <button class="btn btn-success btn-circle btn-outline" type="button" id="copy" title="查找过滤"><i class="fa fa-search"></i></button> -->
                                {% if request.GET.s %}<a href="?">清空搜索</a>{% endif %}
                            </div>
                        </div>
                        {% endif %}
                        <form id="list_object_form" class="form-horizontal  ">

                        {% block list_table %}
                            <!-- 列表页数据 -->

                            <table class="table table-striped table-bordered table-hover dataTables-example">
                                <thead>
                                <tr>
                                    <th width="20"><input type="checkbox" id="CheckedAll"></th>
                                    <th>ID</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>

                                {% for object in object_list %}

                                    <tr id="{{ object.pk }}">
                                        <td><input type="checkbox" value="{{ object.pk }}"  name="id"></td>
                                        <td class="center">{% url viewname_detail object.pk as obj_detail %}
                                            <a href="{% firstof obj_detail '#' %}">{{ object.pk }}</a>
                                        </td>

                                        <td>{% url viewname_update object.pk as obj_update %}
                                            {% if obj_update %}<a class="btn btn-info btn-xs" href="{{ obj_update }}">编辑</a>{% endif %}

                                            {% if objects_delete %}<a class="btn btn-danger btn-xs">删除</a>{% endif %}

                                        </td>

                                    </tr>
                                {% endfor %}


                                </tbody>

                            </table>

                        {% endblock %}

                        </form>

                        {% if is_paginated %}
                            {% if request.GET.s %}
                                {% add "&s=" request.GET.s as s %}
                            {% endif %}
                        <ul class="pagination pull-right">
                            {% if page_obj.has_previous %}
                            <li class="footable-page-arrow"><a href="?{{ s }}">«</a></li>
                            <li class="footable-page-arrow"><a href="?page={{ page_obj.previous_page_number }}{{ s }}">‹</a></li>
                            {% endif %}

                            {% for p in page_obj.paginator.page_range %}
                            {% if page_obj.number == p %}
                            <li class="footable-page active"><a>{{ p }}</a></li>
                            {% else %}
                            <li class="footable-page"><a href="?page={{ p }}{{ s }}">{{ p }}</a></li>
                            {% endif %}
                            {% endfor %}

                            {% if page_obj.has_next %}
                            <li class="footable-page-arrow"><a href="?page={{ page_obj.next_page_number }}{{ s }}">›</a></li>
                            <li class="footable-page-arrow"><a href="?page=last{{ s }}">»</a></li>
                            {% endif %}
                        </ul>
                        {%endif%}


                    </div>

                </div>
            </div>
        </div></div>
    </div>


{% endblock %}



{% block footer-js %}

    <script src="{% static 'js/my.js' %}"></script>

    <script>
        $(function () {

            $('.btn-danger').click(function () {
                // 删除model表obj数据
                DeleteObj(this)
            });

        });

    </script>


    {% block list_js %}
        <!-- 列表页js -->
    {% endblock %}

{% endblock %}
